<?php
namespace app\common\model;
use app\common\model\Base;
class Profit extends Base
{
    protected $auto = [];
    protected $insert = ['status'=>1];
    protected $update = [];

    protected function setDateAttr($value){
    	return strtotime($value);
    }

	protected function _filter($data){
		if(isset($data['date'])){
			$stime =0;
			$etime =0;
			if(strpos('至',$data['date'])){
				$date = explode('至', $data['date']);
				$stime = strtotime($date[0]);
				$etime = strtotime($date[1]);
			}else{
        		$stime = strtotime($data['date'].'-01');
        		$date = new \DateTime(date('Y-m-d',$stime));
        		$etime = $date->add(new \DateInterval('P1M'))->getTimestamp();
			}
			$data['date']=['between',[$stime,$etime]];
		}
		if(isset($data['keywords'])){
			if($data['keywords']){
				$data['account|nickname'] = array('like','%'.$data['keywords'].'%');
			}
		}
        unset($data['keywords']);
		return $data;
	}
}
